/*
 * @(#)NameConsistencyChecker.java   09/10/12
 * 
 * Copyright (C) 2009 Ecole des Mines d'Ales
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact: yulinz88@gmail.com
 */



package fr.ema.arch3d.model.consistencyChecker;

import fr.ema.arch3d.model.architecture.specification.ComponentRole;
import fr.ema.arch3d.model.architecture.specification.Specification;

//~--- classes ----------------------------------------------------------------

/**
 * Class description
 *
 *
 * @version 1.0, 09/09/18
 * @author Huaxi (Yulin) ZHANG
 */
public class NameConsistencyChecker {

    /**
     * Check the new added component role whether has a same name with one of the
     * component role in the existing specification.
     *
     * @param spec  the existing specification that this component role wants to add.
     * @param cmpRole  the new component role should be checked.
     */
    public static void check(Specification spec, ComponentRole cmpRole) {
        for (int i = 0; i < spec.getCmpRoleList().size(); i++) {
            if (cmpRole.getName().equals(spec.getCmpRoleList().get(i).getName())) {
                System.err.println("The component role \'" + cmpRole.getName()
                                   + "\' with the same name has already existed in " + spec.getName());
            }
        }
    }
}
